package com.atguigu.system.controller;


import com.atguigu.model.system.SysLoginLog;

import com.atguigu.model.vo.SysLoginLogQueryVo;
import com.atguigu.springsecurity.service.LoginLogService;
import com.atguigu.system.utils.R;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(value = "SysLoginLog管理", tags = "SysLoginLog管理")
@RestController
@RequestMapping(value="/admin/system/sysLoginLog")
@SuppressWarnings({"unchecked", "rawtypes"})
public class SysLoginLogController {
	
	@Resource
	private LoginLogService sysLoginLogService;

	@ApiOperation(value = "获取分页列表")
	@PostMapping("{page}/{limit}")
	public R index(
		@ApiParam(name = "page", value = "当前页码", required = true)
		@PathVariable Long page,
	
		@ApiParam(name = "limit", value = "每页记录数", required = true)
		@PathVariable Long limit,
	
		@ApiParam(name = "sysLoginLogVo", value = "查询对象", required = false)
                @RequestBody(required = false) SysLoginLogQueryVo sysLoginLogQueryVo) {
		Page<SysLoginLog> pageParam = new Page<>(page, limit);
		IPage<SysLoginLog> pageModel = sysLoginLogService.selectPage(pageParam, sysLoginLogQueryVo);
		return R.ok().put("data", pageModel);
	}

	@ApiOperation(value = "获取")
	@GetMapping("get/{id}")
	public R get(@PathVariable Long id) {
		SysLoginLog sysLoginLog = sysLoginLogService.getById(id);
		return R.ok().put("data", sysLoginLog);
	}
}